<?php

/**
 * This file is part of the Artsopolis Calendar Plugin.
 *
 * (c) vulh@elinext.com <http://elinext.com>
 *
 * This source file is subject to the elinext.com license that is bundled
 * with this source code in the file LICENSE.
 */
if (!session_id()) {
    session_start();
}
?>
<div class="wrap artsopolis-calendar-frontend">
    <div class="wrap-inner">
        <?php 
        if(! empty($ac_options['title'])): ?>
        <div class="produce-wrap">
            <div class="produce-wrap-inner">
                <h2><?php echo $ac_options['title'] ?></h2>
            </div>
        </div>
        <?php endif; ?>
        
        <div class="content-can-filter">
        <div class="content-can-filter-inner">  
            
        
        <div class="content">
            <div class="content-inner">
                
                <div id="artsopolis-calendar-filter" class="filter" style="background-color: <?php echo isset($ac_options['settings_display_color']) ? $ac_options['settings_display_color']: '#e7e7e7'; ?> !important">
                    <div class="filter-inner">
                        <div class="filter-item inner-full">
                            <input name="keyword" class="keyword m-r-10" id="keyword" placeholder="Keyword" />
                            
                            <?php 
                            if(! empty($ac_category)): ?>
                                <div class="category-filter filter-item">
                                    <select class="m-r-10" name="category" placeholder="Category" id="filter-by-category">
                                        <option value=""> Category </option>

                                        <?php 
                                        $sub_prefix = '';
                                        $category_list = array ();
                                        foreach($ac_category as $key => $val): $category_list[] = $key;?>
                                            <?php if (isset($val['name']) && $val['name']): $sub_prefix = '-- ';?>
                                            <option value="<?php echo $key ?>[+]<?php echo $val['name']; ?>"> <?php echo $val['name']; ?></option>
                                            <?php endif; ?>
                                            
                                            <?php 
                                                // Display the list subs cat
                                            	if (! isset($val['subs']) && ! $val['subs']) continue;
                                            	foreach ($val['subs'] as $key => $sub_name) :$category_list[] = $key; 
                                        	?>
												<option value="<?php echo $key ?>[+]<?php echo $sub_name; ?>"><?php echo $sub_prefix. $sub_name; ?></option>
											<?php endforeach; ?>	
                                        <?php endforeach; ?>
                                    </select>
                                    
                                    <input value="<?php echo implode(',', $category_list); ?>" type="hidden" name="category-list" id="category-list" />
                                    <input type="hidden" name="tags-category" id="tags-category" category-name="" />
                                </div>
                            <?php endif; ?>
                            
                            <?php if($ac_filter_location == 1): ?>
                                <div class="location-filter filter-item">
                                    <select name="location" placeholder="Location" id="filter-by-location">
                                        <option value=""> Location </option>
                                        <?php foreach ($locations as $location) : ?>
                                            <option value="<?php echo $location; ?>"><?php echo $location; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </div>
                            <?php endif; ?>
                            
                            <?php if($ac_filter_date == 1): ?>
                            <div class="date-filter filter-item">
                                <div class="date-filter-from-to">
                                    <div class="date-filter-from-wrapper">
                                        <input type="text" name="from_date" placeholder="Start date" class="from-date  m-r-10" id="artsopolis-calendar-filter-from-date" /> 
                                    </div>
                                    <div class="date-filter-to-wrapper">
                                        <input type="text" name="to_date" placeholder="End date" class="end-date" id="artsopolis-calendar-filter-to-date"/>
                                    </div>
                                </div>
                            </div>
                            <?php endif; ?>
                            
                            <div class="filter-item">
                                 <div class="date-util">
                                    <?php if($ac_filter_date == 1): ?> 
                                    <a href="javascript:void(0);" id="artsopolis-calendar-choice-today" 
                                       data-date-from="<?php echo date("Y-m-d", time()) ?>"
                                       data-date-to="<?php echo date("Y-m-d", time()) ?>"
                                       class="button button-gray ac-btn-filter">Today</a>
                                    <a href="javascript:void(0);" id="artsopolis-calendar-choice-tomorrow"
                                       data-date-from="<?php echo date("Y-m-d", strtotime("+1 day")) ?>"
                                       data-date-to="<?php echo date("Y-m-d", strtotime("+1 day")) ?>"
                                       class="button button-gray ac-btn-filter">Tomorrow</a>
                                    <a href="javascript:void(0);" id="artsopolis-calendar-choice-weekend"
                                       data-date-from="<?php echo date("Y-m-d", strtotime("next Saturday")) ?>"
                                       data-date-to="<?php echo date("Y-m-d", strtotime("next Sunday")) ?>"
                                       class="button button-gray ac-btn-filter">This Weekend</a>
                                    <?php endif; ?>   
                                    <a href="javascript:void(0);" id="reset"
                                       class="button button-gray">Reset</a>   
                                </div>
                                
                            </div>
                        </div>
                        
                        <div style="clear:both" ></div>
                    </div>
                </div><!-- #end filter -->
              
                <div class="powered-by"><?php echo $ac_options['content']; ?></div>
                
                <div <?php if (! isset($_GET['event_id'])) echo 'class="list"'; ?> id="artsopolis-calendar-list-feed">
                    <?php echo $html_events; ?>
                </div>
                
                <!-- Only required it in the list events -->                
	                <div class="pagination" id="artsopolis-calendar-pagination"></div>
                    <script type="text/javascript">
                            var artsopolis_calendar_paging = {
                                total_event: <?php echo isset($total_event) && $total_event ? $total_event : 0; ?>,
                                page_size: <?php echo isset($page_size) && $page_size ? $page_size : 0; ?>
                            };
                    </script>
    
            </div>
        </div>
        </div><!-- #content-can-filter-inner-->
    </div><!-- #content-can-filter-->
    </div>
</div><!-- #wrap -->